package org.example.intern.utils;


import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.ToString;
import org.springframework.http.HttpStatus;

@Data
@AllArgsConstructor
public class Rest<T> {
    @ApiModelProperty("请求状态码")
    private Integer code;
    @ApiModelProperty("返回数据")
    private T data;
    @ApiModelProperty("返回信息")
    private String msg;

    public static Rest success(Object data){
        return success(data,"请求成功");
    }
    public static Rest success(Object data, String msg){
        return success(HttpStatus.OK.value(), data, msg);
    }

    public static Rest success(Integer code, Object data,String msg){
        return new Rest(code, data, msg);
    }

    public static Rest faild(Integer code, String msg){
        return new Rest(code, null , msg);
    }

    public static Rest faild(String msg){
        return new Rest(HttpStatus.BAD_REQUEST.value(), null , msg);
    }

}
